package cn.t.web.android;

import cn.t.annotation.Runtime;
import cn.t.facade.order.WorkOrderFacade;
import cn.t.runtime.dto.DeviceWorkOrderDetailRequest;
import cn.t.runtime.dto.DeviceWorkOrderRequest;
import cn.t.vo.andriod.AndroidWorkOrderVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 工单设备端接口
 */
@Slf4j
@RestController
@RequestMapping("runtime")
@AllArgsConstructor
@Runtime
public class AndroidWorkOrderController {

    private final WorkOrderFacade workOrderFacade;

    /**
     * 工单明细
     */
    @PostMapping("/workOrder/detail")
    public AndroidWorkOrderVO detail(@Validated @RequestBody DeviceWorkOrderDetailRequest request) {
        return workOrderFacade.detail(request.getWorkOrderSn(), request.getImei());
    }

    /**
     * 工单列表
     */
    @PostMapping("/workOrder/list")
    public List<AndroidWorkOrderVO> getWorkOrders(@RequestBody @Validated DeviceWorkOrderRequest request) {
        return this.workOrderFacade.getWorkOrders(request);
    }

}

